#!/bin/sh

SELF=$(readlink -f "$0")

if [ "$#" -ne 1 ] || ! [ -d "$1" ]
then
	echo "Usage: $SELF build-dir"
	exit 1
fi

BDIR="$1"
SDIR=$(dirname "$SELF")
EDIR=$(dirname "$SDIR")

echo "Elektra Source is assumed at $EDIR, build directory is given at $BDIR"

# quit with error if cbmc fails
set -ex

ARG="--depth 200 -D ELEKTRA_BMC"
EINC="-I $EDIR/src/include -I $BDIR/src/include"
YINC="-I /usr/include/yajl -I $BDIR/src/plugins/yajl"

cd $EDIR/src/plugins/yajl
cbmc --function elektraYajlSet $ARG $YINC $EINC yajl_gen.c

cd $EDIR/src/libs/elektra
cbmc -D HAVE_KDBCONFIG_H --function kdbSet $ARG $EINC kdb.c


